package cn.boysoft.core.client.xml;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.methods.PostMethod;

import cn.boysoft.core.model.message.Request;
import cn.boysoft.core.model.message.xml.XMLRequest;
import cn.boysoft.core.util.XmlUtil;
import cn.boysoft.module.security.model.entity.UserEntity;

public class XmlClient {
	public static void main(String[] args) throws HttpException, IOException{
		for(int i=0;i<1;i++){
		HttpClient http = new HttpClient();
		URI uri = new URI("http://localhost:9099");
		PostMethod method = new PostMethod();
		method.setURI(uri);
		UserEntity user = new UserEntity();
		user.setUserName("fuhoujun");
		Request request = new XMLRequest();
		request.setData(user);
		request.setServiceId("01_02_02_03");
		String jsonStr = XmlUtil.toXml(request);
		method.setRequestBody(jsonStr);
		http.executeMethod(method);
		String response = method.getResponseBodyAsString();
		System.out.println(response);
		}
	}
}
